<?php
/**
 * APP 内部使用
 * Created by 
 * Date: 2017/12/12
 */


function call_api($apiurl,$parameter){
	
	include_once($_SERVER['DOCUMENT_ROOT']."/Mapi/library/curl.class.php");
	
	$out_data = array('code' => '', 'data'=>'');
	$http_host =  "http://".$_SERVER['HTTP_HOST'];
	$curl = new curl($http_host);

	$result = $curl->post($apiurl,$parameter,true);
	$res_data = $curl->object_array(json_decode($result));
	$res_code = $res_data['response']['message']['msg_code'];
	
	if($res_code ==1){
		$out_data['code'] = 1;
		$out_data['data'] = $res_data['response']['data'];
	}else{
		$out_data['code'] = $res_code;
		$out_data['data'] = '';
		$out_data['msg'] = $res_data['response']['message']['msg_desc'];
	}
	
	return $out_data;
		
}

function html_pagination($html_url,$page_size,$page_more){
	
	$page_start = $page_size-1;
  	$page_end = $page_size+1;
	
	if($page_start < 1){
		$page_up = 'class="sdi"';
	}else{
		$page_up = 'href="'.$html_url.'&page='.$page_start.'"';
	}
	
	if($page_more['more']>0){
		$page_down = 'href="'.$html_url.'&page='.$page_end.'"';
	}else{
		$page_down = 'class="sdi"';;
	}
	
	$html = '';
	if($page_start == 0 && $page_more['more']==0){
		$html = '';
	}else{
		$html ='<div class="pagination"><div class="l_box"><a '.$page_up.'>上一页</a></div>
    	<div class="r_box"><a '.$page_down.'>下一页</a></div></div>';
	}
	return $html;
}
?>